package dbops;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Description   : Functional Test Script
 * @author angel.tsvetkov
 */

/**
 * DBConnection class purpose is to manipulate DB connection
 */
public class DBConnection extends Alias
{
	private Connection con = null;

	public Connection getConnection()
	{
		return con;
	}
	
	protected void closeConnection() {
		try {
			if(con != null)
			{
				con.close();
			}
		} catch (SQLException e) {
			setErrorComment("CLOSE CONNECTION ASSERTION.", e);
		}
	}
	
	protected void openConnection() 
	{
		try {
			Class.forName(getDB_DRIVER());	

		} catch(java.lang.ClassNotFoundException e) {
			setErrorComment("DB Driver can't be loaded.", e);
		}

		try {
		   con = DriverManager.getConnection(getDB_URL(), getUSERID(), getPASSWORD());
		} catch(SQLException ex) {
			setErrorComment("Connection can't be opened.", ex);
		}
	}
}

